#include <iostream>
using std::endl;
using std::cout;
class fun{
public:
    void operator()(){
        cnt++;
        cout<<"hello"<<endl;     
    }
    void operator()(int num){
        cnt++;
        cout<<"num:"<<num<<endl;
    }
    double operator()(double num){
        cnt++;
        return num;
    }
    void gets(){
        cout<<"cnt:"<<cnt<<endl;
    }
private:
    int cnt=0;
};
void display(int num){
    cout<<"display: "<<num<<endl;
}

void display1(double num){
    cout<<"double:"<<num<<endl;
}
void test0(){
    //函数对象
    fun fu;
    fu();
    fu(3);
    cout<<fu(4.5)<<endl;
    
    fu.gets();

}
typedef void(*Function)(double);
typedef void(fun::*m_fun)();
//函数指针
void test1(){
    void (*p)(int) = display;
    p(4);
    void (*p1)(double) = display1;
    p1(9.8);
    Function f=display1;
    f(4.8);
    fun ff;
    m_fun fff= &fun::gets; 
    (ff.*fff)();
    
}
int main()
{
    test1();
    std::cout << "Hello world" << std::endl;
    return 0;
}

